<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const list = [{ id: 1 }, { id: 2 }]
    const list2 = [...list]

    // list.forEach((item, index) => {
    //   console.log('list[index] === list2[index]', list[index] === list2[index])
    // })

    // 1. [] 表示新创建的数组实例，两个[]比较是false
    // console.log('list === list2  ----->  ', list === list2);



    // 2. 截取的数组与原数组是不是同一个了
    // const list3 = list.slice()
    // list.forEach((item, index) => {
    //   console.log('list[index] === list2[index]', list[index] === list3[index])
    // })
    // console.log('list3 == list  ----->  ', list3 === list);

    // 3. 
    const list4 = list.map(item => ({ ...item }))
    list.forEach((item, index) => {
      console.log('list[index] === list2[index]', list[index] === list4[index])
    })

  </script>
</body>

</html>